package com.cnhis.cloudhealth.clinical.clidoctor.acolsetting.dao;

import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSON;
import com.cnhis.cloudhealth.clinical.util.SpringUtilV3_prjcli;
import com.cnhis.cloudhealth.clinical.util.cache.MyConcurrentMapCacheManager;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.dao.BaseDao;
import com.google.common.collect.Maps;
@SuppressWarnings("rawtypes")
@Repository
public class IcolSettingDao extends BaseDao {
	
	
	public static void main(String[] args) {
	//	 public static String cfgFileDir;
		SpringUtilV3_prjcli.cfgFileDir="C:\\0wkspc\\clinical\\target\\classes\\META-INF\\springtest_cli";				
			SpringUtilV3_prjcli.setLocations("applicationContext-datasource.xml,onehis-dubbo.xml");
	 
			IcolSettingDao d=	(IcolSettingDao) SpringUtilV3_prjcli.getBean( IcolSettingDao.class);
		 
			ConcurrentMap<String, Object> newConcurrentMap = Maps.newConcurrentMap();
			newConcurrentMap.put("key", "key1");newConcurrentMap.put("val", "val1");
		//	System.out.println(d.setSetting(newConcurrentMap));
			System.out.println(JSON.toJSONString(d.getSetting(newConcurrentMap))  );
		 
	}


	 

	public Object setSetting(Map map) {
		//com.cnhis.cloudhealth.clinical.util.cache.MyConcurrentMapCacheManager
 //System.out.println(MyConcurrentMapCacheManager);
		
		for (Object k1 : map.keySet()) {
			String k=(String) k1;
			String v=(String) map.get(k);
			v=v.replace("'", "''");
			map.put(k, v);
		}
 
		 
		try {
			return    insert("IcolSetting.insert_datadic", map);
		} catch (Exception e) {
		throw new RuntimeException(e);
		}
	}
 //+target+'_'+args+'_'+caches"   getSetting_  #root.targetClass 
//	+ #root.methodName"  ,key="targetClass+methodName+'_'+ "
	// my ken gener   IcolSettingDao.getSetting:3388397-
	 @Cacheable(   value={ "Cachename12" })
	public Object getSetting(Map map) {
		try {
			return    getSqlSession().selectList("IcolSetting.select_datadic", map);
		} catch (Exception e) {
		throw new RuntimeException(e);
		}
		//return new ModelVo();// Maps.newConcurrentMap();
	}
}
